using System;
using System.Globalization;
using System.Runtime.Serialization;

namespace UnitTesting.Fixturing
{
	[Serializable]
	public class RecursiveValueException : ValueProviderException
	{
		//
		// For guidelines regarding the creation of new exception types, see
		//    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
		// and
		//    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
		//

		public RecursiveValueException()
		{
		}

		public RecursiveValueException(string message) : base(message)
		{
		}

		public RecursiveValueException(string message, Exception inner) : base(message, inner)
		{
		}

		internal RecursiveValueException(Type type) :
			base(string.Format(CultureInfo.InvariantCulture, "The type '{0}' has the same type parameter in constructor. " +
			                                                 "It causes recursive execution, so to avoid it specify explicit argument value for the recursive type parameter.", Ensure.IsNotNull(() => type)))
		{
		}

		protected RecursiveValueException(
			SerializationInfo info,
			StreamingContext context) : base(info, context)
		{
		}
	}
}